home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / gradient-example.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  2.3 KB  |  71 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Gradient example script --- create an example image of a custom gradient
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. (define (script-fu-gradient-example width
  23.                     height
  24.                     gradient-reverse)
  25.   (let* ((img (car (gimp-image-new width height RGB)))
  26.      (drawable (car (gimp-layer-new img width height RGB
  27.                     "Gradient example" 100 NORMAL-MODE)))
  28.  
  29.      ; Calculate colors for checkerboard... just like in the gradient editor
  30.  
  31.      (fg-color (* 255 (/ 2 3)))
  32.      (bg-color (* 255 (/ 1 3))))
  33.  
  34.     (gimp-context-push)
  35.  
  36.     (gimp-image-undo-disable img)
  37.     (gimp-image-add-layer img drawable 0)
  38.  
  39.     ; Render background checkerboard
  40.  
  41.     (gimp-context-set-foreground (list fg-color fg-color fg-color))
  42.     (gimp-context-set-background (list bg-color bg-color bg-color))
  43.     (plug-in-checkerboard 1 img drawable 0 8)
  44.  
  45.     ; Render gradient
  46.  
  47.     (gimp-edit-blend drawable CUSTOM-MODE NORMAL-MODE
  48.              GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
  49.              FALSE 0 0 TRUE
  50.              0 0 (- width 1) 0)
  51.  
  52.     ; Terminate
  53.     (gimp-image-undo-enable img)
  54.     (gimp-display-new img)
  55.  
  56.     (gimp-context-pop)))
  57.  
  58. (script-fu-register "script-fu-gradient-example"
  59.             _"Custom _Gradient..."
  60.             "Create an example image of a custom gradient"
  61.             "Federico Mena Quintero"
  62.             "Federico Mena Quintero"
  63.             "June 1997"
  64.             ""
  65.             SF-ADJUSTMENT _"Width"            '(400 1 2000 1 10 0 1)
  66.             SF-ADJUSTMENT _"Height"           '(30 1 2000 1 10 0 1)
  67.             SF-TOGGLE     _"Gradient reverse" FALSE)
  68.  
  69. (script-fu-menu-register "script-fu-gradient-example"
  70.              _"<Toolbox>/Xtns/Script-Fu/Utils")
  71.